#!/bin/sh
project_home="/users/u060888/P2PN/P2PProject/"
port=50000
superNode=""
#ip="10.185.18.166"
ip="127.0.0.1"
maxVisible=3
max=40 #Max number of peers
i=1

#create super node
superNode=130.225.16.145":"50000
  
cd ${project_home}

RANDOM=$$$(date +%s)


while [ $i -le $max ] #Number of peers to create
do
  porti=$(($port+$i))
  id=P$i
  folder=$project_home/folder/$((($RANDOM%10)+1))
  nrNeighbors=$((($RANDOM%10)+1))
  capacity=$(($RANDOM%3)) #computatinal/bandwith capacity of a node
  

  
  #create super node
  if [ $i -le $maxVisible ]
  then
	xterm -e "java -jar P2PN.jar $porti $id $nrNeighbors $superNode $capacity $folder" &
  else
   	java -jar P2PN.jar $porti $id $nrNeighbors $superNode $capacity $folder&
  fi
  
  i=$(($i+1))

  sleep "1"
done